<template>
  <div class="w-[100%] h-[100%]">

    <div class="mt-[30px]">
      <ContentWrap>
        <SearchBox :queryForm="searchList" :showExpland="true" @query="handleSearchQuery"/>
      </ContentWrap>
    </div>


    <div class="mt-[30px] flex items-center">

      <div class="bg w-[14px] h-[14px] mr-[5px]"
           style="background-image: url(https://img.alicdn.com/imgextra/i1/801089336/O1CN01eYDHP42Ipwk9q9ztR_!!801089336.png)"></div>

      已选 <span class="text-[#3721FF]">1</span> 项

      <el-button
        type="primary"
        @click="handleBtnClick({type:'againTotal'})"
        round
        color="rgba(55,33,255,1)"
        style="color: #fff"
        class="ml-[10px]"
      >
        <Icon icon="ep:promotion" style="color: #fff"/>
        再次发送
      </el-button>

      <el-button
        type="primary"
        @click="handleBtnClick({type:'export'})"
        round
        s-ze="large"
        color="rgba(55,33,255,0.06)"
        style="color: #3721FF"
        class="ml-[10px] w-[96px]"
      >
        导出
      </el-button>

    </div>

    <div class="mt-[30px]">
      <QueryTable
        :list="dataList"
        :total="total"
        :btns="tableBtnList"
        @execute="handleBtnClick"
        v-model="queryParams"
        :thead="th"
        :show-action="true"
      />

    </div>
  </div>
</template>
<script setup lang="ts">
import Icon from "@/components/Icon/src/Icon.vue"
import QueryTable from "@/components/TableData/index.vue"
import ImagePreview from "@/components/ImagePreview/index.vue"
import type {TradeOrderQueryVO} from "@/api/mall/trade/order";
import {DICT_TYPE, getIntDictOptions} from "@/utils/dict";
import type {PurchaseAdvice} from "@/api/purchase/advice/type";

const searchList: TradeOrderQueryVO[] = [
  {
    label: '订单编号',
    code: 'orderNo',
    type: 'input'
  },

  {
    label: '地区',
    code: 'area',
    type: 'select',
    options: [
      {
        label: '中国',
        value: 'CN'
      },
      {
        label: '美国',
        value: 'US'
      }
    ]
  },
  {
    label: '下单日期',
    code: 'orderTime',
    type: 'dateRange'
  },
  {
    label: '商品信息',
    code: 'shopInfo',
    type: 'input',
    placeHolder: '商品名称/商品ID/sku'
  },
  {
    label: '下单信息',
    code: 'orderInfo',
    type: 'input'
  },
  {
    label: '下单链接',
    code: 'orderLink',
    type: 'input'
  },
  {
    label: '物流单号',
    code: 'no ',
    type: 'input'
  },
  {
    label: '归属部门',
    code: 'dept',
    type: 'select',
    options: [
      {
        label: '中国',
        value: 'CN'
      },
      {
        label: '美国',
        value: 'US'
      }
    ]
  },
  {
    label: '归属人员',
    code: 'dept',
    type: 'select',
    options: [
      {
        label: '中国',
        value: 'CN'
      },
      {
        label: '美国',
        value: 'US'
      }
    ]
  },
  {
    label: '订单来源',
    code: 'dept',
    type: 'select',
    options: [
      {
        label: '中国',
        value: 'CN'
      },
      {
        label: '美国',
        value: 'US'
      }
    ]
  },
  {
    label: 'IP',
    code: 'no',
    type: 'input'
  },
  {
    label: '留言/备注',
    code: 'message',
    type: 'input'
  },
  {
    label: '订单状态',
    code: 'status',
    type: 'select',
    options: getIntDictOptions(DICT_TYPE.TRADE_ORDER_STATUS)
  },
  {
    label: '是否有物流单',
    code: 'status',
    type: 'select',
    options: getIntDictOptions(DICT_TYPE.TRADE_ORDER_STATUS)
  },
  {
    label: '是否推物流',
    code: 'dept',
    type: 'select',
    options: [
      {
        label: '中国',
        value: 'CN'
      },
      {
        label: '美国',
        value: 'US'
      }
    ]
  },
  {
    label: '是否有效订单',
    code: 'dept',
    type: 'select',
    options: [
      {
        label: '中国',
        value: 'CN'
      },
      {
        label: '美国',
        value: 'US'
      }
    ]
  },
  {
    label: '物流状态',
    code: 'dept',
    type: 'select',
    options: [
      {
        label: '中国',
        value: 'CN'
      },
      {
        label: '美国',
        value: 'US'
      }
    ]
  },
  {
    label: '内部编码',
    code: 'no',
    type: 'input'
  },
  {
    label: '支付方式 ',
    code: 'dept',
    type: 'select',
    options: [
      {
        label: '中国',
        value: 'CN'
      },
      {
        label: '美国',
        value: 'US'
      }
    ]
  },
  {
    label: '支付单号',
    code: 'no',
    type: 'input'
  }
]
const initQueryParams = {
  pageNo: 1, pageSize: 10
}

const tableBtnList = ref([
  {
    color: '#3721FF',
    code: 'again',
    name: '再次发送'
  },

]);


const th = ref([
  {
    name: '订单号',
    code: 'orderNo',
    type: 'numberRanger',
    search: true
  },
  {
    name: '收货人手机',
    code: 'phone',
    type: 'date',
    search: true
  },
  {
    name: '地区',
    code: 'area',
    search: false
  },
  {
    name: '短信内容',
    code: 'content',
    type: 'numberRanger',
    search: true
  },
  {
    name: '短信类型',
    code: 'type',
    search: false
  },
  {
    name: '推送状态',
    code: 'status',
    search: false
  },
  {
    name: '失败原因',
    code: 'reason',
    search: false
  },
  {
    name: '发送时间',
    code: 'sendTime',
    search: false
  },
]);
const dataList = ref<PurchaseAdvice[]>([
  {
    orderNo: "20201109160037",
    phone: "15823522193",
    area: "新疆",
    content: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    type: "已发货通知",
    status: "是",
    reason: "失败原因",
    sendTime: "2025-09-09 00:00:00"
  },
  {
    orderNo: "20201109160037",
    phone: "15823522193",
    area: "新疆",
    content: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    type: "已发货通知",
    status: "是",
    reason: "失败原因",
    sendTime: "2025-09-09 00:00:00"
  },
  {
    orderNo: "20201109160037",
    phone: "15823522193",
    area: "新疆",
    content: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    type: "已发货通知",
    status: "是",
    reason: "失败原因",
    sendTime: "2025-09-09 00:00:00"
  }


]);
const ids = ref<Array<string | number>>([]);
const total = ref(0);

const initRow = {
  cover: null,
  sku: null,
  spec: null,
  name: null,
  productId: null,
  advice: null,
  occupy: null,
  stock: null,
  inTransit: null,
  noAuditInTransit: null,
}

const selectedRow = ref<PurchaseAdvice>({...initRow})

const isShowDialog = ref(false)


const queryParams = ref({
  ...initQueryParams
})

const handleSearchQuery = (val) => {
  /***
   * 搜索框查询条件，目前考虑在查询时 queryParams = {...val,pageNo:1,pageSize:10}
   * */
  console.log(val, 'handleSearchQuery')
}

const handleBtnClick = e => {
  let type = e.type;
  try {
    fn[type](e)
  } catch (e) {
    console.log(`${type}不存在`)
  }
}

const fn = {
  againTotal({data}) {
    selectedRow.value = data.row;
    isShowDialog.value = true
  },
  export() {

  },
  again({data: {row}}) {
    console.log(row)
  }
}


</script>
<style lang="scss" scoped>

</style>
